Repository navigation
fix(tracker-core): [#2916] remove source locations from tracker-core errors - #2991
Conversation
…ror texts name no source path Unit tests at the tracker-core seams (whitelist authorization, the authentication service, the shared driver tests and the keys handler) and protocol tests through the UDP, HTTP and REST API servers. The REST helper assert_unhandled_rejection now also forbids source paths, and the ErrorKind::Whitelist payload tests pin the full message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ist and authentication key errors WhitelistError::TorrentNotWhitelisted and the UnableToReadKey, KeyExpired and MissingAuthKey variants of authentication::key::Error no longer hold a location. The UDP error response, the HTTP failure reason and the ErrorKind::Whitelist event payload built from them now hold no source path. KeyExpired and MissingAuthKey become unit variants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…se errors InsertFailed, UpdateFailed and DeleteFailed no longer hold a location, and the 12 driver sites that build them emit a tracing event naming the driver and the table instead. The LocatedError sources of the other variants become plain shareable sources, and the sqlx and migrate conversions lose #[track_caller]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r key errors and drop torrust-located-error PeerKeyError and authentication::key::Error keep their source errors as plain sources, so the REST API texts built from them hold no source path. tracker-core no longer depends on torrust-located-error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cation failure reasons without source paths Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uns and the manual verification Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
What changed in this PR
Removes source-location recording/printing from tracker-core errors (per ADR), ensuring UDP/HTTP/REST messages and event payloads no longer contain .../file.rs:line paths.
Changes:
- Dropped
Location::caller()/LocatedErrorusage from tracker-core errors and updated call sites across DB drivers + auth/whitelist flows. - Added/updated tests and shared assertions to ensure error texts contain no source paths (unit + integration/contract).
- Updated docs/spec evidence to record manual verification and test runs; removed
torrust-located-errordependency fromtracker-core.
| File | Description |
|---|---|
| packages/udp-server/tests/server/contract.rs | Adds UDP contract coverage ensuring whitelist errors contain no source paths. |
| packages/udp-server/tests/server/asserts.rs | Introduces assert_names_no_source_path helper for UDP server tests. |
| packages/udp-server/src/event.rs | Updates whitelist error construction and pins whitelist event payload message text. |
| packages/tracker-core/src/whitelist/authorization.rs | Removes location capture from WhitelistError and updates tests. |
| packages/tracker-core/src/test_helpers.rs | Adds assert_names_no_source_path helper for tracker-core tests. |
| packages/tracker-core/src/statistics/event/handler.rs | Updates test double to construct UpdateFailed without location. |
| packages/tracker-core/src/error.rs | Removes LocatedError sources and location fields; updates error formatting/tests. |
| packages/tracker-core/src/databases/error.rs | Removes location from DB errors; replaces located sources with Arc<dyn Error>; updates conversions and adds tests. |
| packages/tracker-core/src/databases/driver/sqlite/whitelist_store.rs | Replaces location-based errors with warnings + location-free error variants. |
| packages/tracker-core/src/databases/driver/sqlite/auth_key_store.rs | Replaces location-based errors with warnings + location-free error variants. |
| packages/tracker-core/src/databases/driver/postgres/whitelist_store.rs | Replaces location-based errors with warnings + location-free error variants. |
| packages/tracker-core/src/databases/driver/postgres/auth_key_store.rs | Replaces location-based errors with warnings + location-free error variants. |
| packages/tracker-core/src/databases/driver/mysql/whitelist_store.rs | Replaces location-based errors with warnings + location-free error variants. |
| packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs | Replaces location-based errors with warnings + location-free error variants. |
| packages/tracker-core/src/databases/driver/mod.rs | Extends shared driver tests to assert no source paths in failure strings. |
| packages/tracker-core/src/authentication/service.rs | Removes location usage from auth errors and adds tests for location-free messages. |
| packages/tracker-core/src/authentication/key/peer_key.rs | Adds derives to keep PeerKeyError (Clone/Eq) compatible without LocatedError. |
| packages/tracker-core/src/authentication/key/mod.rs | Removes location/located-error usage from key errors; updates conversions and tests. |
| packages/tracker-core/src/authentication/handler.rs | Removes Located(..).into() wrapping and adds tests asserting no source paths in chained errors. |
| packages/tracker-core/Cargo.toml | Drops torrust-located-error dependency. |
| packages/http-core/src/services/scrape.rs | Updates tests to construct tracker-core errors without location. |
| packages/http-core/src/services/error_mapping.rs | Updates tests/helpers for location-free auth/whitelist errors. |
| packages/http-core/src/services/announce.rs | Removes MissingAuthKey location capture and updates tests accordingly. |
| packages/axum-rest-api-server/tests/server/v1/contract/context/auth_key.rs | Adds REST contract tests to ensure DB failure reasons contain no source paths. |
| packages/axum-rest-api-server/tests/server/v1/asserts.rs | Enhances rejection assertions to forbid source-path fragments; adds helper. |
| packages/axum-http-server/tests/server/v1/contract/failure_reasons_hold_no_source_path.rs | Adds HTTP contract coverage for whitelist/auth failure reasons without source paths. |
| packages/axum-http-server/src/v1/extractors/authentication_key.rs | Updates module docs to show new location-free failure reasons. |
| docs/issues/open/2916-2912-si-4-tracker-core/manual-verification-evidence.md | Adds manual verification evidence (before/after) and procedures. |
| docs/issues/open/2916-2912-si-4-tracker-core/evidence/tests-red-udp-server-lib.txt | Stores red test output for UDP server library (pre-fix). |
| docs/issues/open/2916-2912-si-4-tracker-core/evidence/tests-red-udp-server-integration.txt | Stores red test output for UDP integration test (pre-fix). |
| docs/issues/open/2916-2912-si-4-tracker-core/evidence/tests-red-tracker-core.txt | Stores red test output for tracker-core (pre-fix). |
| docs/issues/open/2916-2912-si-4-tracker-core/evidence/tests-red-axum-rest-api-server.txt | Stores red test output for REST API server (pre-fix). |
| docs/issues/open/2916-2912-si-4-tracker-core/evidence/tests-red-axum-http-server.txt | Stores red test output for HTTP server (pre-fix). |
| docs/issues/open/2916-2912-si-4-tracker-core/evidence/tests-green.txt | Stores green test output after fix. |
| docs/issues/open/2916-2912-si-4-tracker-core/evidence/responses-before.txt | Captures manual responses before fix (contain source paths). |
| docs/issues/open/2916-2912-si-4-tracker-core/evidence/responses-after.txt | Captures manual responses after fix (no source paths). |
| docs/issues/open/2916-2912-si-4-tracker-core/ISSUE.md | Updates spec status/progress log/acceptance criteria with evidence. |
| cspell.json | Excludes new evidence folder from spellchecking. |
Review effort: Lite
…omes and the bencode terminator in samples Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ads of PR torrust#2991 round 1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 951df21ed66e39926bde962d53cb17fe036ba464. Recomputed from the bytes at this head, against the merge base 4be22ee66; git merge-tree against develop 4be22ee66 merges without conflict, and the merged tree equals this head's tree.
Process: a bug fix under the repository's fix-bug skill, with open-pull-request, commit-changes and process-pr-review, applying docs/adrs/20261118045443_errors_do_not_record_source_locations.md.
The change against its claim: the seven location variants, the LocatedError sources of databases::error::Error, KeyVerificationError and PeerKeyError, the six Located(err).into() calls, both #[track_caller] conversions and the dependency go as described, and every builder and matcher follows. The red runs recompute (6/160, 3/14, 1/17, 9/60), each panic on a new assertion; each new test fails with the fix reverted; the AC1, AC2 and AC5 greps reproduce. The last three commits reword the verify_auth_key doc, which now follows its control flow, explain the bencode terminator, and add the review audit.
Review audit: both threads opened before the last audit commit have a reply on their own thread, a row and a resolution. The validator's logic, run offline over the capture, reports ok, 2 rows, 0 failures.
Consistency: links resolve; the open-pull-request commit-id check prints nothing; the cspell.json glob covers the evidence folder; nothing is moved or renamed.
Hygiene: nine Conventional subjects with [#2916], author equal to committer on each. Each commit carries an attribution footer; no rule in the tree forbids one. Only the implemented issue is closed, and no commit message or the title holds a closing keyword. git diff --check reports one line (F4).
Findings
- F1 Minor: a REST module doc still shows a source path in a reply this change fixes.
- F2 Minor:
UnableToReadKeykeeps and prints the peer key against ADR rule 3, now pinned by a test. - F3 Minor: the red and green commands are not recorded; three driver steps were never seen red.
- F4 Nit: a blank line at the end of
tests-green.txt. - F5 Suggestion: the path assertion now exists in seven copies.
- F6 Nit: the evidence counts eleven requests; both captures hold twelve.
None blocks.
Checked, no finding: the persisted-whitelist pre-check behind W2 and W3; the driver tracing events carry no key; UpdateFailed kept with reasons; the diagram deferred to SI-6 as stated.
Checks
On the loop's compute node at this head, against the merge base 4be22ee66 (receipt server-gates-kranich-1304): the repository's pre-commit gate and lint roster exit 0 (258 s wall), and the audit validator passes on this PR's record (2 rows, 0 failures). The two crates this head's last code commit touches (torrust-tracker-core and torrust-tracker-axum-http-server) were cleaned from the per-PR target directory before measuring, so both were rebuilt at this head: cargo test --workspace passes 4449 tests with 0 failed and 5 ignored across 131 binaries (114 s wall), and cargo clippy --workspace --all-targets --all-features -- -D warnings is clean (14 s wall). cargo deny check exits 5 with the same 35 license rejections and four advisories as recent runs on develop, so this pull request changes nothing in that result. Checked against the bytes at posting: packages/tracker-core/src/authentication/key/mod.rs:176-177 keeps UnableToReadKey { key: Box<Key> } with the message Failed to read key: {key}, as F2 says. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "". At posting, develop is 4be22ee66.
|
ACK 951df21 — removal of every tracker-core location field and LocatedError source, its consumers, the red-run evidence, the acceptance greps and the review audit with its validator logic recomputed at this head |
…reply without a source path Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…istered-key message The test no longer pins the peer key in the message, so it does not entrench a text that ADR rule 3 may remove. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…runs of the three later driver steps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f PR torrust#2991 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ads of PR torrust#2991 round 2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 5024c26be7f35b4d1c96cfb3176f9e26d1f4bddc. Recomputed from the bytes at this head, against the merge base 4be22ee66; git merge-tree against develop 4be22ee66 merges without conflict, and the merged tree equals this head's tree.
Process: this round reads the five commits since the last reviewed head, two fast-forwards, under the fix-bug and process-pr-review skills.
The change against its claim: d7f012b33 puts the recorded K3 reply in the REST delete-key example; 4bc4266a6 makes the unregistered-key test check the prefix and the absence of a path, so it stays red with the fix reverted; b47aa94ba records the ten commands, adds a stamped red run of each of the three later driver steps (each path names the red-test commit's line), drops the trailing blank line and says twelve; 7aab8e81c and 5024c26be add audit rows F3 to F8 and then record their replies and resolutions.
Earlier findings: F1, F3, F4 and F6 are fixed. F2: the test no longer pins the key; the variant still keeps and prints it (key/mod.rs:176), and the reply hands that to the maintainer, which I accept; it stays listed as Minor and is not re-posted. F5 is answered without change, deferred to SI-6.
Review audit: each of the eight threads has an author reply on its own thread, an audit row citing that reply's URL, and a resolution. The five fixed rows are RESOLVED; the no-change row is NO_ACTION/SUPERSEDED with its reply URL as the resolution reference, as process-pr-review requires. The validator's logic, run offline over the capture, reports ok, 8 rows, 0 failures, so F7 is fixed.
Consistency and hygiene: the links resolve; the open-pull-request commit-id check prints nothing; git diff --check is clean; the five new subjects are Conventional with [#2916] and author equals committer; each commit carries an attribution footer, which no rule in the tree forbids; no new closing keyword appears.
Findings
- F2 Minor (standing, answered):
UnableToReadKeystill keeps and prints the peer key; the follow-up is the maintainer's.
None blocks.
Checked, no finding: no thread or review appeared since the last capture; the new import sits in the module that uses it; the audit's F3 grep finds no path; the earlier approval was dismissed automatically by a push.
Checks
On the loop's compute node at this head, against the merge base 4be22ee66 (receipt server-gates-kranich-1314): the repository's pre-commit gate and lint roster exit 0 (88 s wall), and the audit validator passes on this PR's record (8 rows, 4 log entries, 0 failures). This head differs from 7aab8e81c only in docs/pr-reviews/pr-2991-review/PR-REVIEW.md, so the package measurements made there (receipt server-gates-kranich-1309) hold: in the per-PR target directory, with every changed crate rebuilt, cargo test --workspace passes 4449 tests with 0 failed and 5 ignored across 131 binaries (87 s wall), cargo clippy --workspace --all-targets --all-features -- -D warnings is clean, and cargo deny check exits 5 with the same 35 license rejections and four advisories as recent runs on develop. Checked against the bytes at posting: the record now carries 16 distinct discussion_r reply URLs, up from 10 at 7aab8e81c, the gap F7 named. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "". At posting, develop is 4be22ee66.
|
ACK 5024c26 — the round-2 fixes, the recorded red runs and the review audit, whose eight rows match their replied and resolved threads and pass the validator logic, recomputed at this head |
|
ACK 5024c26 |
Issue #2916 (SI-4 of EPIC #2912) closed with the merge of PR #2991. Sets status done and the remaining checkpoints, repairs the parent EPIC link, points the evidence at the new spec path, records the move of the peer key finding to EPIC #2993, and marks SI-4 DONE in the EPIC's sub-issue table. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ssues/closed 7a44641 chore(issues): archive closed issue #2916 spec to docs/issues/closed (josecelano-bot) Pull request description: Archives the spec of issue #2916 (SI-4 of EPIC #2912, closed on GitHub with the merge of PR #2991) from `docs/issues/open/` to `docs/issues/closed/`. - Verified issue #2916 is `CLOSED` on GitHub. - Updated the frontmatter (`status: done`, `spec-path`, `last-updated-utc`), ticked the checkpoints left open at implementation time and added the close-out entry to the progress log. - Repaired the parent EPIC link in the spec, pointed the evidence at the new spec path and marked SI-4 `DONE` in the EPIC's sub-issue table. - Recorded where the two follow-ups went: the peer key printed by `UnableToReadKey` is in the standalone EPIC #2993, and the seven copies of the source-path assertion helper are being specified as SI-8 in a separate spec-only PR. - The audit record of PR #2991 keeps the `docs/issues/open/...` paths in its recorded verification commands, as it is a historical record. Documentation only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: josecelano: ACK 7a44641 Tree-SHA512: 87e1d2167e3bca33d041e6c5f27acd7ed84abea2822843ca7f0226fa8d72684b1303d4fc79d55ab11ac8c36a27840b0088e7a7243f427a5de1e0d122dcf08bdb


Closes #2916
Sub-issue SI-4 of EPIC #2912 ("Remove source locations from errors"), following the ADR
docs/adrs/20261118045443_errors_do_not_record_source_locations.md. Specification:docs/issues/open/2916-2912-si-4-tracker-core/ISSUE.md.Summary
The errors of
torrust-tracker-coreno longer record or print a source location, so no UDP error message, HTTP failure reason, REST API error text or event payload built from them holds apackages/...rs:linepath.WhitelistError::TorrentNotWhitelistedandauthentication::key::Error::{UnableToReadKey, KeyExpired, MissingAuthKey}lose theirlocationfield (the last two become unit variants). Build sites:whitelist/authorization.rs,authentication/service.rs,authentication/key/mod.rsandhttp-core/src/services/announce.rs.databases::error::Error::{InsertFailed, UpdateFailed, DeleteFailed}loselocationat the variant and at the 12 driver sites (SQLite, MySQL, PostgreSQL; whitelist and key stores). The message names the driver but not the table, so each site now emits atracing::warn!with the driver, the table and, for the whitelist, the info-hash (never the key).LocatedErrorsources become plain sources: the four ofdatabases::error::Error(anArc<dyn Error + Send + Sync>, so the type staysClone),PeerKeyError::{InvalidKey, DatabaseError}(the sixLocated(err).into()calls inauthentication/handler.rsgo) andauthentication::key::Error::KeyVerificationError. The two#[track_caller]conversions lose the attribute.ParseKeyErrorderivesClone,PartialEqandEq.packages/tracker-core/Cargo.tomlno longer depends ontorrust-located-error.UpdateFailedis kept: no production code builds it, but it is a public variant of a#[non_exhaustive]enum and a test double uses it; the reasoning is in the spec's progress log.axum-http-server/src/v1/extractors/authentication_key.rsnow show the real tracker-core failure reasons.Before and after, from the manual verification:
Tests
test(tracker-core): [#2916] add red tests that tracker-core error texts name no source path): unit tests at the tracker-core seams (whitelist authorization, authentication service, the shared driver tests, the keys handler) and protocol tests through the UDP server (contract test), the HTTP server (failure_reasons_hold_no_source_path.rs, three new cases) and the REST API server (two new key tests;assert_unhandled_rejectionnow also forbids source paths, which turns the seven existing database-failure tests into checks too). The fourudp-serverErrorKind::Whitelisttests pin the full payload.InsertFailed,UpdateFailed,DeleteFailed, a convertedsqlxerror andKeyVerificationError.#[track_caller]appears only on the test assertion helpersassert_names_no_source_path.Validation
docs/issues/open/2916-2912-si-4-tracker-core/evidence/.manual-verification-evidence.mdin the spec folder.linter all(stable Rust 1.100.0, nightly rustfmt),cargo clippy --workspace --all-targets --all-features -- -D warnings, and the tests oftracker-core,http-core,udp-core,udp-server,rest-api-runtime-adapter,axum-http-serverandaxum-rest-api-serverpass. The MySQL and PostgreSQL driver tests were not run locally (they need the database containers); their change is the same as the SQLite one.Not in this PR
udp-servervariantsInternalandAuthRequired(SI-5) and droppingtorrust-located-errorfrom the workspace (SI-6). The dependency diagram indocs/media/packages/dependencies-workspace-packages.mdstill drawstracker-core --> located-err; SI-6 redraws it.UnableToReadKeystill prints the peer key ("Failed to read key: "), as before. That is a secret-leak and client-text question, not a source-location one, so it is outside this PR and outside EPIC EPIC: Remove source locations from errors #2912: it moves to the standalone EPIC EPIC: Keep secrets out of errors, logs and client replies, and make client error text safe #2993 ("Keep secrets out of errors, logs and client replies, and make client error text safe"). Related to EPIC: Keep secrets out of errors, logs and client replies, and make client error text safe #2993.🤖 Generated with Claude Code